// dreamApi.js - 解梦服务API
import apiService from './api';
import { logInfo, logError } from '../logger';

/**
 * 调用AI解梦API
 * @param {string} dreamContent - 梦境内容
 * @returns {Promise<Object>} 解梦结果
 */
export const interpretDream = async (dreamContent) => {
  try {
    logInfo('调用AI解梦API', { dreamContent });
    
    const response = await apiService.request('/dreams/interpret', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ dreamContent }),
    });
    
    logInfo('AI解梦API调用成功', { dreamId: response.data?.dream?.id });
    return response.data.dream;
  } catch (error) {
    logError('AI解梦API调用失败', { error: error.message, dreamContent });
    throw error;
  }
};

export default {
  interpretDream
};